package com.pengtu.gsj.controller.yh;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.yh.DamageDisease;
import com.pengtu.gsj.service.yh.DamageDiseaseService;

@Controller
@RequestMapping("disease")
public class DamageDiseaseController  extends DefaultBaseController{
	
	@Autowired
	private DamageDiseaseService damageDiseaseService;

	/**
	 * 
	 * showListInfo:
	 * 适用:跳转到显示病害信息页面
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping("listInfo")
	public String showListInfo(){
		return "yh/damageDisease_list";
	}
	
	/**
	 * 
	 * getDamageDiseaseList:
	 * 适用:jqgrid请求病害数据
	 * @param page
	 * @param request
	 * @return  病害及页面信息
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<DamageDisease> getDamageDiseaseList(Page<DamageDisease> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("createDate");
			page.setOrder(Page.DESC);
		}
		page = damageDiseaseService.getDamageDiseaseList(page, queryFilter);
		return page;
	}
}
